package com.example.redistest.ThreadDemo;

public class ThreadDemo2 implements Runnable {
    private String name;
    public ThreadDemo2 (String name){
        this.name = name;
    }
    public static int  num = 10000000;
    @Override
    public void run() {
        Object obj = new Object();
        while (true){
            synchronized (obj){
                System.out.println(num+"........");
                num--;
                System.out.println("num:....."+num);
            }

        }

        /*for (int i=0; i<5; i++){
            System.out.println(name+"运行"+i);
        }*/

       /* try {
            Thread.sleep((long) Math.random()*10);
        }catch (Exception e){
            e.printStackTrace();
        }*/
    }

    public static void main(String[] args) {
        Thread thread1 = new Thread(new ThreadDemo2("A"));
        Thread thread2 = new Thread(new ThreadDemo2("B"));
        thread1.start();
        thread2.start();
    }
}
